'use strict';
// const db = uniCloud.database();
const cloud = require('wx-server-sdk')
cloud.init({
	env: "dev-avbw2"
})
let response = function(code, data, msg) {
	return {
		code: code,
		data: data,
		msg: msg || '成功'
	}
}
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log(event, '——————拿到的参数————————',cloud.getWXContext())
	// if (event.api == 'test') {
		let abc = cloud.getWXContext() // 这里获取到的 openId 和 appId 是可信的
		console.log("____",abc)
		return response(10000, {
			"OPENID": abc,
			"APPID": "APPID"
		}, '成功')
	// }
};


/**
 * 新增海报
 * @param {String}  authorId 创建者 
 * @param {String}  posterUrl 海报Url
 * @param {String}  familyId  家庭Id
 * @param {String}  sortNum  优先级
 * @param {String}  createTime  创建时间
 * */
let newAddposterLog = async (param) => {
	if (!param.authorId || !param.posterUrl)
		return response(20000, undefined, '参数错误')
	let collection = await db.collection('bmPoster');
	let result = await collection.add(param)
	return response(10000, result)
};
